Ext.define('DCApp.view.img.Detail', {
    extend: 'DCApp.view.Detail',
    alias: 'widget.imagedetail',
    
    requires: [
       'Ext.form.Panel',
       'Ext.form.field.Text',
       'Ext.form.field.TextArea',
       'Ext.layout.container.VBox',
       'Ext.layout.container.Anchor',
       'Ext.form.field.ComboBox',
       'Ext.view.View',
       'DCApp.Cfg'
    ],
    
    bind: {
        title: '影像 - 【{theObj.id}】'
    },
    
    tbar: ['->',{
        text: '上一条',
        handler: 'onPrev',
        bind: {
            hidden: '{!showprev}'
        }
    },{
        text: '下一条',
        handler: 'onNext',
        bind: {
            hidden: '{!shownext}'
        }
    },{
        text: '保存',
        handler: 'onSaveClick',
        bind: {
            hidden: '{!showsave}'
        }
    },{
        text: '返回',
        handler: 'onBackClick',
        bind: {
            hidden: '{!showreturn}'
        }
    }],
    
    componentCls: 'img-detail',
    bodyPadding: 0,
    
    controller: 'imgdetail',
    
    
    items: [{
    	listeners: {
		  render: function(p){
			p = p.getEl();
			var me= this.up();
			me.h0=p.getHeight();
		    p.on('scroll', function(e, t){
		    	//console.log(t.scrollTop +"   "+ t.clientHeight);
		    	me.onscroll(t.scrollTop,t.clientHeight);
		    }, p);
		  }
		},
    	title: 'Panel 0',
    	padding:'0 0 50 0', 
        flex: 2,
        frame: false,
        xtype: 'container',
        layout: 'anchor',
        style: {
            overflow: 'auto'
        },
        items: [
                {
                    title: '影像信息',
                    margin: '0 0 10 0',
                    cls:'nav_pos',
                    bodyPadding: 10,
                    fieldDefaults: {
                        labelAlign: 'right',
                        labelWidth: 100,
                        padding:3
                    },
                    defaults: {
                        anchor: '100%'
                    },
                    xtype: 'form',
                    reference: 'form',
                    items: [{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '影像来源',
                			bind : '{theObj.imageSource}',
                            xtype: 'combobox',
                            listeners:{
					                        	focus:function( fld, evt, eOpts ){
					                        		fld.onTriggerClick();
					                        	}
					                        },
                            triggerAction:'all',
                            typeAhead :true,
                           	minChars:1,
                           	lazyInit:false,
                            queryParam : 'kw',
 				          	typeAhead :true,
                            valueField: 'name',
                            displayField: 'name',
                            store: DCApp.Cfg.getDistinctStore('com.cl.entity.Image','imageSource')
                        }, {
                            flex: 2,
                            fieldLabel: '影像名称',
                            xtype: 'textfield',
                			bind : '{theObj.imageName}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '对象编号',
                            xtype: 'textfield',
                			bind : '{theObj.objNo}'
                        }, {
                            flex: 2,
                            fieldLabel: '对象名称',
                            xtype: 'textfield',
                			bind : '{theObj.objName}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '类型',
                			bind : '{theObj.imgType}',
                            xtype: 'combobox',
                            listeners:{
					                        	focus:function( fld, evt, eOpts ){
					                        		fld.onTriggerClick();
					                        	}
					                        },
                            triggerAction:'all',
                            typeAhead :true,
                           	minChars:1,
                           	lazyInit:false,
                            queryParam : 'kw',
 				          	typeAhead :true,
                            valueField: 'name',
                            displayField: 'name',
                            store: DCApp.Cfg.getDistinctStore('com.cl.entity.Image','imgType')
                       }, {
                            flex: 2,
                            fieldLabel: '颜色',
                			bind : '{theObj.imgColor}',
                            emptyText: '影像颜色',
                            xtype: 'combobox',
                            listeners:{
					                        	focus:function( fld, evt, eOpts ){
					                        		fld.onTriggerClick();
					                        	}
					                        },
                            triggerAction:'all',
                            typeAhead :true,
                           	minChars:1,
                           	lazyInit:false,
                            queryParam : 'kw',
 				          	typeAhead :true,
                            valueField: 'name',
                            displayField: 'name',
                            store: DCApp.Cfg.getDistinctStore('com.cl.entity.Image','imgColor')
                        }
                        ]
                    },
                    {

                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [
                            DCApp.Cfg.getAuthorField('作者','{theObj.photographer}'),
                        {
							flex: 2,
                            fieldLabel: '用途',
                            xtype: 'combobox',
                            listeners:{
					                        	focus:function( fld, evt, eOpts ){
					                        		fld.onTriggerClick();
					                        	}
					                        },
                            triggerAction:'all',
                            typeAhead :true,
                           	minChars:1,
                           	emptyText :'请选择',
 				          	typeAhead :true,
                            valueField: 'name',
                            displayField: 'name',
                            store: ['集体','个人'],
                            bind: '{theObj.usage}'
							}]
                     },
                    {
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [
                        	{
                            flex: 2,
                            fieldLabel: '光盘卷标',
                            xtype: 'displayfield',
                			bind : '{theObj.cdlabel}'
                        }, {
                            flex: 2,
                            fieldLabel: '文件名',
                            xtype: 'displayfield',
                			bind : '{theObj.imgFile}'
                        }]
                    },
                    
                     {

                         xtype: 'container',
                         layout: 'hbox',
                         combineErrors: true,
                         defaultType: 'textfield',
                         
                         items: [
                                 DCApp.Cfg.getEditorField('登记人','{theObj.dcEditor0}'),
                                 {
                                 	flex: 2,
                            		fieldLabel: '目标影像序号',
                                 	bind : '{theObj.dcPid}'
                                 }
                          ]

                      },
                     {
                         xtype: 'fileupload',
                         height:'auto',
                         entity_to:'Image',
                     	 accept:"image/png, image/jpeg",
                         fieldLabel: '影像文件',
                         bind: {
                        	 value:'{theObj.pathMiddle}',
                        	 entity_id:'{theObj.id}',
                             hidden: '{!theObj.b_hide_img}' 
                         }
                     },{
                    	xtype: 'displayfield',
                    	//bind: '{theObj.uri_img}',
                    	bind: {
                            value: '{theObj.uri_img}',
                            hidden: '{theObj.b_hide_img}'
                        },
                    	fieldLabel: '大影像',   

                    	renderer:function(uri,v2,v3){
                    		if(uri==""||uri==null)
        		        		return "";  
        				    return	'<a target="_blank" href="'+uri+'">'
        				    	+uri+'</a>';
                    	}
                       },{
                    	xtype: 'displayfield',
                    	//bind: '{theObj.uri_m}',
                    	bind: {
                            value: '{theObj.uri_m}',
                            hidden: '{theObj.b_hide_img}'
                        },
                    	fieldLabel: '中影像',   
                    	renderer:function(uri,v2,v3){
                    		if(uri==""||uri==null)
        		        		return "";  
        				    return	'<a target="_blank" href="'+uri+'">'
        				    	+uri+'</a>';
                    	}
                       },{
                    	xtype: 'displayfield',
                    	//bind: '{theObj.uri}',
                    	bind: {
                            value: '{theObj.uri}',
                            hidden: '{theObj.b_hide_img}'
                        },
                    	fieldLabel: '小影像',   
                    	renderer:function(uri,v2,v3){
                    		if(uri==""||uri==null)
        		        		return "";  
        		        	//uri+="&size=90";
        				    return	'<a target="_blank" href="'+uri+'">'
        				    	+uri+'</a>';
                    	}
                       },
                    	{
                    	xtype: 'displayfield',
                    	//bind: '{theObj.uri_m}',
                    	bind: {
                            value: '{theObj.uri_m}',
                            hidden: '{theObj.b_hide_img}'
                        },
                    	fieldLabel: '预览',   
                    	//height:200,
                    	renderer:function(uri,v2,v3){
                    		var fld = v2;
        		        	if(uri==""||uri==null)
        		        		uri="/resources/images/no_image_available.jpg";  
        				    return	"<img src='"+uri+"'>\"";
                    	},
                    	listeners:{
                    		change:function(fld, eOpts ){
                    			var img = fld.getEl().down('img');                    			
                    			img.on({
                    				scope: this,
                    				load: this.imgload,
                    				single:true
                    			});
                    		}
                    	},
                    	imgload:function(v1,v2,v3){
                    		var dp = this.up('container');
                    		setTimeout(function(){
								dp.updateLayout();
							},100);                      		
                    	}
                       },
                       
                     {
                    	xtype: 'htmleditor',
                    	 plugins:[{ptype: 'word'}],
                    	bind: {value:'{theObj.description}'},
                    	publishes: ['value'],
                    	fieldLabel: '影像说明'                    		                    		
                       }]
                },{

                    title: '登记信息',
                    collapsible: true,
	                collapsed:true,
                    margin: '0 0 10 0',
                    cls:'nav_pos',
                    bodyPadding: 10,
                    fieldDefaults: {
                        labelAlign: 'right',
                        labelWidth: 100,
                        padding:3
                    },
                    /*defaults: {
                        anchor: '100%'
                    },
                    xtype: 'form',*/
	                defaults: {
	                              labelWidth: 89,
	                              anchor: '100%',
	                              layout: {
	                              type: 'hbox',
	                              defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
	                            }
	                         },
                    xtype: 'fieldset',
                    items: [
                    	{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '存放路径',
                            xtype: 'displayfield',
                			bind : '{theObj.cdNo}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '影像提供单位',
                            xtype: 'displayfield',
                			bind : '{theObj.provider}'
                        }, {
                            flex: 2,
                            fieldLabel: '扫描文件后缀',
                            xtype: 'displayfield',
                			bind : '{theObj.scanSuffix}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '登记人',
                            xtype: 'displayfield',
                			bind : '{theObj.registerMan}'
                        }, {
                            flex: 2,
                            fieldLabel: '登记时间',
                            xtype: 'displayfield',
                			bind : '{theObj.registerTime}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '登记提交接受人',
                            xtype: 'displayfield',
                			bind : '{theObj.regCReceiver}'
                        }, {
                            flex: 2,
                            fieldLabel: '登记提交时间',
                            xtype: 'displayfield',
                			bind : '{theObj.regCTime}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '扫描者',
                            xtype: 'displayfield',
                			bind : '{theObj.scanMan}'
                        }, {
                            flex: 2,
                            fieldLabel: '扫描时间',
                            xtype: 'displayfield',
                			bind : '{theObj.scanTime}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '扫描提交接收人',
                            xtype: 'displayfield',
                			bind : '{theObj.scanReceiver}'
                        }, {
                            flex: 2,
                            fieldLabel: '扫描提交时间',
                            xtype: 'displayfield',
                			bind : '{theObj.scanCTime}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '影像加工者',
                            xtype: 'displayfield',
                			bind : '{theObj.handler}'
                        }, {
                            flex: 2,
                            fieldLabel: '加工时间',
                            xtype: 'displayfield',
                			bind : '{theObj.handleTime}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '图像文件后缀',
                            xtype: 'displayfield',
                			bind : '{theObj.suffix}'
                        }, {
                            flex: 2,
                            fieldLabel: '加工提交时间',
                            xtype: 'displayfield',
                			bind : '{theObj.handleCTime}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '有小图像',
                            xtype: 'displayfield',
                			bind : '{theObj.haveSmall}'
                        }, {
                            flex: 2,
                            fieldLabel: '有中图像',
                            xtype: 'displayfield',
                			bind : '{theObj.haveBigimage}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '中图像的宽',
                            xtype: 'displayfield',
                			bind : '{theObj.mimgWidth}'
                        }, {
                            flex: 2,
                            fieldLabel: '中图像的高',
                            xtype: 'displayfield',
                			bind : '{theObj.mimgHeight}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '有大图像',
                            xtype: 'displayfield',
                			bind : '{theObj.isLivepicture}'
                        }, {
                            flex: 2,
                            fieldLabel: '影像确认结果',
                            xtype: 'displayfield',
                			bind : '{theObj.confirmFlag}'
                        }]
                    },{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [{
                            flex: 2,
                            fieldLabel: '影像确认人',
                            xtype: 'displayfield',
                			bind : '{theObj.confirmMan}'
                        }, {
                            flex: 2,
                            fieldLabel: '影像确认时间',
                            xtype: 'displayfield',
                			bind : '{theObj.confirmTime}'
                        }]
                    }]
                                	
                }
            ]
        }]
});